package com.example.demo.repository;

import com.example.demo.entity.TimingDataEntity;
import com.example.demo.mapper.TimingDataEntityMapper;
import com.timing.finder.framework.DBRepository;
import com.timing.finder.util.SpringUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @author JingGe(* ^ ▽ ^ *)
 * @date 2023-07-17 15:31
 * @email 1158055613@qq.com
 */
public class TimingDataEntityRepository implements DBRepository<TimingDataEntity> {
    @Override
    public List<TimingDataEntity> query(Map<String, Object> params, int batchNum, int batchSize, long startID, long endID) {
        Optional<TimingDataEntityMapper> mapper = SpringUtil.getBeanOptional(TimingDataEntityMapper.class);
        List<TimingDataEntity> res = new ArrayList<>();
        mapper.ifPresent(mp -> res.addAll(mp.selectPaged(startID, endID, (batchNum - 1) * batchSize, batchSize)));
        return res;
    }

    /**
     * 保存方法暂时无需实现
     *
     * @param seriesData 要保存的数据
     * @return int
     * @author JingGe(* ^ ▽ ^ *)
     * @date 2023/7/17 15:32
     */
    @Override
    public int save(List<TimingDataEntity> seriesData) {
        return 0;
    }
}
